<?php

/**
 * @desc 请求ERP
 * @author zhangweifeng@shopex.cn 15-7-7 上午11:02
 */
class b2c_ctl_admin_api {

    private $soap = '';
    private $url = 'http://183.234.115.242:8000/EnjoyRMIS_WS/WCF/WcfECExtend.svc?wsdl';
    private $strKey = '';  
    private $sUserNo = '666666';
    public $sUserName = '网上商城';
    public $sStoreId = '11051';

    function __construct() {
        $this->soap=new SoapClient($this->url);  
        if (empty($this->soap)) {
            exit('soap connect error');
        }   
        $sGUID=$this->createGUID();
        $dtMake=date('Y-m-d H:i:s');  
        $strNote='';
        $strStoreId='';
        $strUserno='';
        $accessKey=$this->soap->GetAccessKey(array($sGUID,$dtMake,$strNote,$strStoreId,$strUserno));
        if (!empty($accessKey) && $accessKey->GetAccessKeyResult == true) {
            $sResult = objectToArray(json_decode($accessKey->sResult));
            $des=new DES('ENJOYCRM');
            $this->strKey=$des->decrypt($sResult['<strKey>']);
        }    
    }
    public function addOrderBill($orderBill,$orderDetail,$orderPay){
        $params=array(
            'orderBill'=>$orderBill,
            'orderDetail'=>$orderDetail,
            'orderPay'=>$orderPay,
        );
        $result=$this->soap->addOrderBill($params);
        return $result;
    }
    
    public function printOeder(){
        $orderBill=array(
            'oId'=>'100010001005',
            'oName'=>'dsdg',
            'eName'=>'ewrty',
            'payment'=>'100.00',
        );
        $orderDetail=array(
            array(
                'oId'=>'100010001005',
                'oName'=>'dsdg',
                'eName'=>'ewrty',
                'payment'=>'100.00',
            ),
            array(
                'oId'=>'100010001005',
                'acId'=>'2',
                'whId'=>'00162',
                'skuId'=>'00162',
            )
        );
        $orderPay=array(
            'oId'=>'100010001005',
            'cAmount'=>'2200.00',
            'cStatus'=>'1',
            'cType'=>'在线支付-银联卡',
            'cBank'=>'支付宝',
        );
        $JorderBill=json_encode($orderBill);
        $JorderDetail=json_encode($orderDetail);
        $JorderPay=json_encode($orderPay);
        dump($this->addOrderBill($JorderBill,$JorderDetail,$JorderPay));
    }
}
